﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SQL1
{
    class Program
    {
        static void Main(string[] args)
        {
            string conStr = "Data Source=192.168.25.108;Initial Catalog=db0;Persist Security Info=True;User ID=sa;Password=MSsql123";
            SqlConnection con = new SqlConnection(conStr);
            string sql = "select * from person";
            SqlCommand cmd = new SqlCommand(sql,con);
            con.Open();
            //int n = (int)cmd.ExecuteScalar();
            SqlDataReader sqlDataReader = cmd.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    Console.WriteLine(sqlDataReader.GetInt32(0)+"   "+sqlDataReader.GetString(1)+"  "+sqlDataReader.GetString(2)+"  "+sqlDataReader.GetInt32(3));
                }
            }
            con.Close();
            con.Dispose();
            Console.ReadKey();
        }
    }
}
